package co.yixiang.yshop.module.tables.controller.app.table;

import co.yixiang.yshop.module.tables.convert.table.AppTableInfoConvert;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import co.yixiang.yshop.framework.common.pojo.CommonResult;
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
import co.yixiang.yshop.module.tables.controller.app.table.vo.*;
import co.yixiang.yshop.module.tables.dal.dataobject.table.TableInfoDO;
import co.yixiang.yshop.module.tables.service.table.TableInfoService;

@Tag(name = "用户 APP - 餐桌")
@RestController
@RequestMapping("/tables/table-info")
@Validated
public class AppTableInfoController {

    @Resource
    private TableInfoService tableInfoService;
    
    /*根据id查询餐桌信息*/
    @GetMapping("/get")
    @Operation(summary = "获得餐桌")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppTableInfoRespVO> getTableInfo(@RequestParam("id") Integer id) {
        TableInfoDO tableInfo = tableInfoService.getTableInfo(id);
        return success(AppTableInfoConvert.INSTANCE.convert(tableInfo));
    }

    @GetMapping("/list")
    @Operation(summary = "获得餐桌列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    public CommonResult<List<AppTableInfoRespVO>> getTableInfoList(@RequestParam("ids") Collection<Integer> ids) {
        List<TableInfoDO> list = tableInfoService.getTableInfoList(ids);
        return success(AppTableInfoConvert.INSTANCE.convertList(list));
    }


}
